package com.sky.mq.rabbit;

import com.sky.configuration.RabbitMQConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 消息队列发送消息
 */
@Component
public class SendRabbitMQ {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * @param orderId 15分钟后要检查的订单编号
     */
    public void sendDelayOrder(Long orderId) {
        rabbitTemplate.convertAndSend(
                RabbitMQConfig.ORDER_EXCHANGE,//订单交换机
                RabbitMQConfig.ORDER_ROUTING,//订单路由键
                orderId//要取消的订单编号
        );
    }
}
